package com.tedu.bank_ems1.controller;

import com.tedu.bank_ems1.entity.Emp;
import com.tedu.bank_ems1.service.EmpService;
import com.tedu.bank_ems1.service.impl.EmpServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * Author：毕龙
 * Date: 2024/6/25 9:34
 */
@WebServlet(value = "/emp/list")
public class EmpListServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //处理请求参数

        //调用业务逻辑
        EmpService service = new EmpServiceImpl();
        List<Emp> emps = service.listEmp();
        request.setAttribute("emps",emps);
        //请求跳转
        request.getRequestDispatcher("/ems/emp/emplist.jsp").forward(request,response);

    }
}
